package com.kashow.bean.circle;

import android.text.TextUtils;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.kashow.bean.BaseBean;

import java.util.List;

/**
 * Created by yybs on 16/11/5.
 */

public class CircleItem extends BaseBean implements MultiItemEntity{
    private static final String TYPE_VIDEO = "video";
    private static final String TYPE_IMAGE = "image";
    /**
     * _id : 1
     * title : 2016-12-15
     * type : 1
     * audio : 1
     * cover : http://oh2ucnq1s.bkt.clouddn.com/aa3b3094fdb54891b7a9d5599d934f98
     * user : {"_id":6,"__v":0,"balance":0,"createdAt":"2016-10-24T06:00:18.633Z","isSub":true,"isTeacher":true,"level":1,"openid":"ohHipv6XJGwrDTVEQSjqjh3PmhKY","relation":4,"score":0,"sex":0,"phone":"15822774691","wxUserInfo":{"openid":"ohHipv6XJGwrDTVEQSjqjh3PmhKY","nickname":"李文跃","sex":1,"city":"West Green","province":"Tianjin","country":"China","headimgurl":"http://wx.qlogo.cn/mmopen/ajNVdqHZLLAYkDOyst27Frh103lm6Eh9uiaXo7RhpiahLmzIHib30Cxs3pGTdz2gk0gFfQMP4FsDcnTdlNvkxicWicA/0","updatedAt":"2016-10-24T06:00:18.000Z"},"authInfo":{"realName":"李文跃","cardNumber":"371528199008289393","cardPic1":"http://oss.kashowvr.com/wx/upload/media/kaAZKKGtlg0tLzq3BTF-VwEqHZKw5n5JVk4I8kI3TzfG3wmz_0NC7oFZKR_RfN8y.jpeg","cardPic2":"http://oss.kashowvr.com/wx/upload/media/U5tk6a2mdoYB5CKr5jnepfFeoztoeGZfG5HXT5xB8FD8hFJSOoKagzFZ9nQthHVF.jpeg","status":1,"updatedAt":"2016-11-18T08:31:30.084Z","createdAt":"2016-11-18T08:31:30.085Z"}}
     * watch : 0
     * content : {"type":"image","item":[{"imageUrl":"http://oh2ucnq1s.bkt.clouddn.com/f41332ad206a47fa8ed093eec8d02df2?1080_1920","text":"李静嘻嘻嘻嘻嘻"},{"imageUrl":"http://oh2ucnq1s.bkt.clouddn.com/99231575b95048a193097653603239b7?1080_1920"},{"imageUrl":"http://oh2ucnq1s.bkt.clouddn.com/1b7b4a54adf449959d87d40100232463?1080_1920"}]}
     * createdAt : 2016-12-15 15:02:58
     * id : 1
     * star : 0
     * hasStared : 0
     */


    private int _id;
    private boolean read;

    public boolean isRead() {
        return read;
    }

    public void setRead(boolean read) {
        this.read = read;
    }

    private String title;
    private int type;
    private AudioBean audio;
    private String cover;
    private UserBean user;
    private int watch;
    private ContentBean content;
    private String createdAt;
    private String id;
    private int star;
    private int hasStared;
    private int hasCollected;

    public int getHasCollected() {
        return hasCollected;
    }

    public void setHasCollected(int hasCollected) {
        this.hasCollected = hasCollected;
    }

    public int get_id() {
        return _id;
    }

    public void set_id(int _id) {
        this._id = _id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public AudioBean getAudio() {
        return audio;
    }

    public void setAudio(AudioBean audio) {
        this.audio = audio;
    }

    public String getCover() {
        return cover;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    public UserBean getUser() {
        return user;
    }

    public void setUser(UserBean user) {
        this.user = user;
    }

    public int getWatch() {
        return watch;
    }

    public void setWatch(int watch) {
        this.watch = watch;
    }

    public ContentBean getContent() {
        return content;
    }

    public void setContent(ContentBean content) {
        this.content = content;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getStar() {
        return star;
    }

    public void setStar(int star) {
        this.star = star;
    }

    public int getHasStared() {
        return hasStared;
    }

    public void setHasStared(int hasStared) {
        this.hasStared = hasStared;
    }

    public static class UserBean {
        /**
         * _id : 6
         * __v : 0
         * balance : 0
         * createdAt : 2016-10-24T06:00:18.633Z
         * isSub : true
         * isTeacher : true
         * level : 1
         * openid : ohHipv6XJGwrDTVEQSjqjh3PmhKY
         * relation : 4
         * score : 0
         * sex : 0
         * phone : 15822774691
         * wxUserInfo : {"openid":"ohHipv6XJGwrDTVEQSjqjh3PmhKY","nickname":"李文跃","sex":1,"city":"West Green","province":"Tianjin","country":"China","headimgurl":"http://wx.qlogo.cn/mmopen/ajNVdqHZLLAYkDOyst27Frh103lm6Eh9uiaXo7RhpiahLmzIHib30Cxs3pGTdz2gk0gFfQMP4FsDcnTdlNvkxicWicA/0","updatedAt":"2016-10-24T06:00:18.000Z"}
         * authInfo : {"realName":"李文跃","cardNumber":"371528199008289393","cardPic1":"http://oss.kashowvr.com/wx/upload/media/kaAZKKGtlg0tLzq3BTF-VwEqHZKw5n5JVk4I8kI3TzfG3wmz_0NC7oFZKR_RfN8y.jpeg","cardPic2":"http://oss.kashowvr.com/wx/upload/media/U5tk6a2mdoYB5CKr5jnepfFeoztoeGZfG5HXT5xB8FD8hFJSOoKagzFZ9nQthHVF.jpeg","status":1,"updatedAt":"2016-11-18T08:31:30.084Z","createdAt":"2016-11-18T08:31:30.085Z"}
         */

        private int _id;
        private int balance;
        private String createdAt;
        private boolean isSub;
        private boolean isTeacher;
        private int level;
        private String openid;
        private int relation;
        private float score;
        private int sex;
        private String phone;
        private String nickname;
        private String headimgurl;
        private WxUserInfoBean wxUserInfo;
        private AuthInfoBean authInfo;

        public int get_id() {
            return _id;
        }

        public void set_id(int _id) {
            this._id = _id;
        }

        public int getBalance() {
            return balance;
        }

        public void setBalance(int balance) {
            this.balance = balance;
        }

        public String getCreatedAt() {
            return createdAt;
        }

        public void setCreatedAt(String createdAt) {
            this.createdAt = createdAt;
        }

        public boolean isIsSub() {
            return isSub;
        }

        public void setIsSub(boolean isSub) {
            this.isSub = isSub;
        }

        public boolean isIsTeacher() {
            return isTeacher;
        }

        public void setIsTeacher(boolean isTeacher) {
            this.isTeacher = isTeacher;
        }

        public int getLevel() {
            return level;
        }

        public void setLevel(int level) {
            this.level = level;
        }

        public String getOpenid() {
            return openid;
        }

        public void setOpenid(String openid) {
            this.openid = openid;
        }

        public int getRelation() {
            return relation;
        }

        public void setRelation(int relation) {
            this.relation = relation;
        }

        public float getScore() {
            return score;
        }

        public void setScore(float score) {
            this.score = score;
        }

        public int getSex() {
            return sex;
        }

        public void setSex(int sex) {
            this.sex = sex;
        }

        public String getPhone() {
            return phone;
        }

        public void setPhone(String phone) {
            this.phone = phone;
        }

        public WxUserInfoBean getWxUserInfo() {
            return wxUserInfo;
        }

        public void setWxUserInfo(WxUserInfoBean wxUserInfo) {
            this.wxUserInfo = wxUserInfo;
        }

        public AuthInfoBean getAuthInfo() {
            return authInfo;
        }

        public void setAuthInfo(AuthInfoBean authInfo) {
            this.authInfo = authInfo;
        }

        public String getNickname() {
            if (TextUtils.isEmpty(nickname) && wxUserInfo != null) {
                nickname = wxUserInfo.getNickname();
            }
            return nickname;
        }

        public void setNickname(String nickname) {
            this.nickname = nickname;
        }

        public String getHeadimgurl() {
            if (TextUtils.isEmpty(headimgurl) && wxUserInfo != null) {
                headimgurl = wxUserInfo.getHeadimgurl();
            }
            return headimgurl;
        }

        public void setHeadimgurl(String headimgurl) {
            this.headimgurl = headimgurl;
        }

        public static class WxUserInfoBean {
            /**
             * openid : ohHipv6XJGwrDTVEQSjqjh3PmhKY
             * nickname : 李文跃
             * sex : 1
             * city : West Green
             * province : Tianjin
             * country : China
             * headimgurl : http://wx.qlogo.cn/mmopen/ajNVdqHZLLAYkDOyst27Frh103lm6Eh9uiaXo7RhpiahLmzIHib30Cxs3pGTdz2gk0gFfQMP4FsDcnTdlNvkxicWicA/0
             * updatedAt : 2016-10-24T06:00:18.000Z
             */

            private String openid;
            private String nickname;
            private int sex;
            private String city;
            private String province;
            private String country;
            private String headimgurl;
            private String updatedAt;

            public String getOpenid() {
                return openid;
            }

            public void setOpenid(String openid) {
                this.openid = openid;
            }

            public String getNickname() {
                return nickname;
            }

            public void setNickname(String nickname) {
                this.nickname = nickname;
            }

            public int getSex() {
                return sex;
            }

            public void setSex(int sex) {
                this.sex = sex;
            }

            public String getCity() {
                return city;
            }

            public void setCity(String city) {
                this.city = city;
            }

            public String getProvince() {
                return province;
            }

            public void setProvince(String province) {
                this.province = province;
            }

            public String getCountry() {
                return country;
            }

            public void setCountry(String country) {
                this.country = country;
            }

            public String getHeadimgurl() {
                return headimgurl;
            }

            public void setHeadimgurl(String headimgurl) {
                this.headimgurl = headimgurl;
            }

            public String getUpdatedAt() {
                return updatedAt;
            }

            public void setUpdatedAt(String updatedAt) {
                this.updatedAt = updatedAt;
            }
        }

        public static class AuthInfoBean {
            /**
             * realName : 李文跃
             * cardNumber : 371528199008289393
             * cardPic1 : http://oss.kashowvr.com/wx/upload/media/kaAZKKGtlg0tLzq3BTF-VwEqHZKw5n5JVk4I8kI3TzfG3wmz_0NC7oFZKR_RfN8y.jpeg
             * cardPic2 : http://oss.kashowvr.com/wx/upload/media/U5tk6a2mdoYB5CKr5jnepfFeoztoeGZfG5HXT5xB8FD8hFJSOoKagzFZ9nQthHVF.jpeg
             * status : 1
             * updatedAt : 2016-11-18T08:31:30.084Z
             * createdAt : 2016-11-18T08:31:30.085Z
             */

            private String realName;
            private String cardNumber;
            private String cardPic1;
            private String cardPic2;
            private int status;
            private String updatedAt;
            private String createdAt;

            public String getRealName() {
                return realName;
            }

            public void setRealName(String realName) {
                this.realName = realName;
            }

            public String getCardNumber() {
                return cardNumber;
            }

            public void setCardNumber(String cardNumber) {
                this.cardNumber = cardNumber;
            }

            public String getCardPic1() {
                return cardPic1;
            }

            public void setCardPic1(String cardPic1) {
                this.cardPic1 = cardPic1;
            }

            public String getCardPic2() {
                return cardPic2;
            }

            public void setCardPic2(String cardPic2) {
                this.cardPic2 = cardPic2;
            }

            public int getStatus() {
                return status;
            }

            public void setStatus(int status) {
                this.status = status;
            }

            public String getUpdatedAt() {
                return updatedAt;
            }

            public void setUpdatedAt(String updatedAt) {
                this.updatedAt = updatedAt;
            }

            public String getCreatedAt() {
                return createdAt;
            }

            public void setCreatedAt(String createdAt) {
                this.createdAt = createdAt;
            }
        }
    }

    public static class ContentBean {
        /**
         * type : image
         * item : [{"imageUrl":"http://oh2ucnq1s.bkt.clouddn.com/f41332ad206a47fa8ed093eec8d02df2?1080_1920","text":"李静嘻嘻嘻嘻嘻"},{"imageUrl":"http://oh2ucnq1s.bkt.clouddn.com/99231575b95048a193097653603239b7?1080_1920"},{"imageUrl":"http://oh2ucnq1s.bkt.clouddn.com/1b7b4a54adf449959d87d40100232463?1080_1920"}]
         */

        private String type; //"video image"
        private List<CircleItemBean> item;

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public List<CircleItemBean> getItem() {
            return item;
        }

        public void setItem(List<CircleItemBean> item) {
            this.item = item;
        }
    }

    @Override
    public int getItemType() {
        if (TYPE_VIDEO.equals(content.getType())){
            return 2;
        } else {
           if (content != null && content.getItem() != null && content.getItem().size() >=3) {
               return 3;
           }
        }
        return 1;
    }


}
